"""
    进程池示例
"""
import multiprocessing
import random
import time
import urllib3

def spider(url):
    try:
        time.sleep(random.randint(1,10))
        res = urllib3.request('GET', url)
        print(res)
    except Exception as exc:
        print(exc)

if __name__ == '__main__':
    pool = multiprocessing.Pool(3)
    urls = [
        'https://www.baidu.com/',
        'https://www.google.com/',
        'https://www.sina.com',
        'https://www.sohu.com',
        'https://www.bankwings.com',
        'https://www.cnpc.com.cn',
        'https://www.ccidit.com',
    ]
    pool.map(spider, urls)
    pool.close()
    pool.join()